# encoding:utf8
"""
@File        : utils.py
@Time        : 2019/7/1814:03
@Author      : zhaoy
@Email       : zhaoyao@shandiangou.cc
@Description : db 链接工具
"""

import pymongo
from sqlalchemy import create_engine


class MongoClient(object):

    def __init__(self):
        client = pymongo.MongoClient(host='192.168.50.181', port=27017)
        self.db = client.ods

    @property
    def mongo_client(self):
        return self.db


class MysqlClient(object):
    def __init__(self):
        DB_CONNECT_DM = 'mysql+pymysql://dw:sdg666888@192.168.50.154:3306/ods'
        self.engine = create_engine(DB_CONNECT_DM, encoding='utf8', echo=True)

    @property
    def mysql_client(self):
        return self.engine


def mongo_client():
    return MongoClient().mongo_client


def mysql_client():
    return MysqlClient().mysql_client

# if __name__ == '__main__':
# db = mongo_client()
# a = db.suning_store.find_one({})
# print(a)
# engine = mysql_client`()
# print(engine)
